function foo(x) {
    console.log(this.a,x);
    
}

const obj = {
    a: 1
}
foo.call(obj, 2)


Function.prototype.myCall = function(...args) {
    //将foo引用到obj上
    //让obj调用foo
    //移除obj上的foo
    const context = args[0]
    const arg = args.splice(1)
    context.foo = this

    context.foo()
    delete context.foo
}


foo.myCall(obj,2, 3, 4)